<?php
require 'libs/ModelBase.php';
class intranetModel extends ModelBase
{
	public function getSobreMiIzquierda(){
		
		$consulta = $this->db->prepare("SELECT * FROM content WHERE id = 1 AND id_field = 1");
		
		$consulta->execute();	
		
		return $consulta;		
	}
	
	public function getSobreMiDerecha(){

		$consulta = $this->db->prepare("SELECT * FROM content WHERE id = 2 AND id_field = 2");
		
		$consulta->execute();
		
		return $consulta;		
	}
	
	public function setSobreMiIzquierda($texto){
		
		$consulta = $this->db->prepare("UPDATE content SET content = ? WHERE id = 1 AND id_field = 1");
		
		if ($consulta->execute(array($texto))) {
			return true;
		}else{
			return false;
		}
	}
	
	public function setSobreMiDerecha($texto){
		
		$consulta = $this->db->prepare("UPDATE content SET content = ? WHERE id = 2 AND id_field = 2");
		
		if ($consulta->execute(array($texto))) {
			return true;
		}else{
			return false;
		}
	}
	
	public function getInfoContacto($id_user){
		$consulta = $this->db->prepare("SELECT * FROM user WHERE id = ?");
		
		$consulta->execute(array($id_user));
		
		return $consulta;
	}
	
	public function getTextContacto(){

		$consulta = $this->db->prepare("SELECT * FROM content WHERE id = 4 AND id_field = 4");
		
		$consulta->execute();

		return $consulta;
	}
	
	public function setContacto($user, $mail, $phone, $facebook, $twitter){
		
		$consulta = $this->db->prepare("UPDATE user SET email = ?, phone_number = ?, facebook = ?, twitter = ? WHERE id = ?");
		
		if ($consulta->execute(array($mail, $phone, $facebook, $twitter, $user))){
			return true;
		}else{
			return false;
		}
	}
	
	public function getAgradecimientos(){
	
		$consulta = $this->db->prepare("SELECT * FROM content WHERE id = 3 AND id_field = 3");
	
		$consulta->execute();
	
		return $consulta;
	}
	
	public function setAgradecimientos($text){
		
		$consulta = $this->db->prepare("UPDATE content set content = ? WHERE id = 3 and id_field = 3");
		
		if ($consulta->execute(array($text))) {
			return true;
		}else{
			return false;
		}
	}
	
	public function setContactoText($text){
		
		$consulta = $this->db->prepare("UPDATE content set content = ? WHERE id = 4 and id_field = 4");
		
		if ($consulta->execute(array($text))) {
			return true;
		}else{
			return false;
		}
	}
	
}
?>